﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TestWin
{
    public partial class DownFileForm : Form
    {
        string m_fileName = "";
        long  m_nDevHandle = 0;
        public DownFileForm(long  nDevHandle ,string  fileName)
        {
            m_fileName = fileName;
            m_nDevHandle = nDevHandle;
            InitializeComponent();

            this.label1.Text = fileName;
        }

        class DownInfo
        {
            public int  state { get; set; }
            public int  pos { get; set; }
            public int  filesize { get; set; }
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (m_fileName != ""){
                string ss =  See51.CSharpSee51Sdk.See51SDKGetFileInfo(m_nDevHandle, m_fileName);
                DownInfo info = Newtonsoft.Json.JsonConvert.DeserializeObject< DownInfo > (ss);
              
                this.progressBar1.Maximum = info.filesize;
                this.progressBar1.Minimum = 0;
                this.progressBar1.Value = info.pos;
                if (info.state == 1 && info.pos == info.filesize)
                {
                    this.button1.Visible = false;
                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }
    }
}
